package com.yxnsh.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
//@RefreshScope
public class PaymentController {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${config.info}")
    private String configInfo;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping(value = "/payment/nacos/{id}")
    public String getPayment(@PathVariable("id") Integer id) {
        return "nacos registry, serverPort: " + serverPort + "\t id" + id;
    }

    /**
     * 配置文件
     * @return
     */
    @GetMapping("/config/info")
    public String getConfigInfo() {
        return configInfo;
    }

    /**
     * 配置文件
     * @return
     */
    @GetMapping("/config/restTemplate")
    public String restTemplate() {
        return restTemplate.getForObject("http://192.168.3.40:8600/proxy/payment/nacos/1", String.class);
    }

}



